package handler

import (
	"github.com/gin-gonic/gin"
	"tvmanager/model"
)

func TvAdd(c *gin.Context) {
	name := c.PostForm("name")
	score := c.PostForm("score")
	data := model.Tv{
		Name:  name,
		Score: score,
	}
	model.DB.Create(&data)
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "OK",
	})
	return
}
func TvList(c *gin.Context) {
	var tv []model.Tv
	model.DB.Find(&tv).Debug()
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "OK",
		"data": tv,
	})
	return
}
